<script>

import * as echarts from 'echarts';
export default {
  name: 'VisualizationNine',
  data() {
    return{

    }
  },
  mounted() {
    this.getData();
  },
  methods:{open1(msg) {
      this.$notify({
        title: msg,
        message: '这是一条成功的提示消息',
        type: 'success'
      });
    },
    open2(msg) {
      this.$notify({
        title: msg,
        message: '这是一条警告的提示消息',
        type: 'warning'
      });
    },
    open4(msg) {
      this.$notify.error({
        title: msg,
        message: '这是一条错误的提示消息'
      });
    },
    getData(){
      this.$axios.get('/api/vis/getData9', {

      }).then(res =>{
        let data = [];
        if (res.data.code === 20041) {
          for (let i = 0; i < res.data.data.length; i++) {
            let param = res.data.data[i]["param"]
            if(param === "2023-12-07") {
              param = "今天";
            }
            data.push(
                { value: res.data.data[i]["param1"], name: param }
            )
          }
        }
        this.init(data);

      }).catch(error =>{
        error = "系统出错了"
        this.open4(error)
      });


    },

    init(data) {

      var chartDom = document.getElementById('main-box9');
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        title: {
          text: '租房入住汇总',
          left: 'center'
        },

        tooltip: {
          trigger: 'item',
          formatter: '{b} : {c} 个'
        },
        legend: {
          orient: 'vertical',
          left: 'left'
        },
        series: [
          {
            name: '汇总',
            type: 'pie',
            radius: '70%',
            data: data,
            emphasis: {
              itemStyle: {
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(255, 0, 0, 0.5)'
              }
            }
          }
        ]
      };

      option && myChart.setOption(option);


    }
  }
}

</script>

<template>
  <div id="main-box9"></div>
</template>

<style scoped>
#main-box9 {
  height: 100%;
  width: 100%;
}
</style>